Skip to content

Fix entropy source selection for Apple cross-compilation targets#3113

Merged
justsmth merged 3 commits intoaws:mainfrom
justsmth:fix-ios-build
Mar 26, 2026
Merged

Fix entropy source selection for Apple cross-compilation targets#3113
justsmth merged 3 commits intoaws:mainfrom
justsmth:fix-ios-build

Conversation

@justsmth
Copy link
Copy Markdown
Contributor

@justsmth justsmth commented Mar 20, 2026

Issues:

Related: aws/aws-lc-rs#1068
Related: #3111

Context:

When cross-compiling for iOS on certain toolchains, TARGET_OS_IPHONE from TargetConditionals.h can evaluate to 0 (e.g., due to compiler/SDK version mismatches). This causes OPENSSL_IOS to not be defined, and the entropy source selection in crypto/rand_extra/internal.h falls through to OPENSSL_RAND_URANDOM, which is inherently Linux-specific. The build then fails in urandom.c due to its use of ioctl() and RNDGETENTCNT.

Description of changes:

The fix widens the CCRandomGenerateBytes branch from OPENSSL_IOS to OPENSSL_APPLE. OPENSSL_APPLE is derived from __APPLE__ (a compiler intrinsic) so it has no dependency on TargetConditionals.h. CCRandomGenerateBytes is available on all Apple platforms, so this is safe regardless of the specific Apple target.

Call-outs:

We considered instead redefining OPENSSL_IOS using a TargetConditionals.h-independent condition (e.g., OPENSSL_APPLE && !OPENSSL_MACOS), but OPENSSL_MACOS depends on the same TargetConditionals.h mechanism and fails in the same way. It would also incorrectly label non-iOS Apple platforms (tvOS, watchOS, etc.) as iOS.

Testing:

Added an iOS aarch64 cross-compilation job to the aws-lc-rs.yml workflow.
This job installs Homebrew LLVM (which reproduces the TargetConditionals.h
detection failure) and builds aws-lc-rs for aarch64-apple-ios.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@justsmth
Copy link
Copy Markdown
Contributor Author

justsmth commented Mar 20, 2026

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.20%. Comparing base (666d5e3) to head (102bf44).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3113      +/-   ##
==========================================
- Coverage   78.22%   78.20%   -0.03%     
==========================================
  Files         689      689              
  Lines      122073   122073              
  Branches    17030    17029       -1     
==========================================
- Hits        95491    95465      -26     
- Misses      25677    25702      +25     
- Partials      905      906       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread crypto/rand_extra/internal.h
@justsmth justsmth enabled auto-merge (squash) March 26, 2026 15:10
@justsmth justsmth disabled auto-merge March 26, 2026 17:05
@justsmth justsmth merged commit 91122ed into aws:main Mar 26, 2026
452 of 457 checks passed
@justsmth justsmth deleted the fix-ios-build branch March 26, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants